/*
 * Toedo
 * Copyright (C) 2009-2010 J. Devauchelle and contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 3 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package org.toedo.logging;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class Log {
	
private static Log _instance = null;
	
	private static Logger theLogger;
	private static String FQCN = Log.class.getName();
	
	private Log() {};
	
	public static Log getInstance() {
		if (_instance == null) {
			_instance = new Log();
		}
		
		theLogger = Logger.getRootLogger();
		return _instance;
	}
	
	public static Log getInstance(Class<?> theClass) {
		if (_instance == null) {
			_instance = new Log();
		}
		
		theLogger = Logger.getLogger(theClass);
		return _instance;
	}	
	
	public void info(String msg) {
		theLogger.log(FQCN, Level.INFO, msg, null);
    }
	
	public void debug(String msg) {
		theLogger.log(FQCN, Level.DEBUG, msg, null);
    }
	
	public void warn(String msg) {
		theLogger.log(FQCN, Level.WARN, msg, null);
    }
	
	public void error(String msg) {
		theLogger.log(FQCN, Level.ERROR, msg, null);
    }

}
